package com.tyqx.hashchainutil.com.example.demo.controller;


import java.io.IOException;
import java.util.Base64;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import com.tyqx.hashchainutil.com.example.demo.service.impl.FabricServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class FabricController {
    @Autowired
    private FabricServiceImpl fabricService;
    @RequestMapping("query")
    @ResponseBody
    public String query(HttpServletRequest request){
        String key = request.getParameter("key");
        return fabricService.query(key);
    }

    @RequestMapping("invoke")
    @ResponseBody
    public String invoke (HttpServletRequest request){
        String type = request.getParameter("type");
        String num = request.getParameter("num");
        String a="a",b="b",result;
        if(type=="1"){
            result = fabricService.invoke(a,b,num);
        }else {
            result = fabricService.invoke(b,a,num);
        }
        return result;
    }
     
    @RequestMapping("/test")
    public String test(){
    	System.out.println("112131232132");
        return "index";
    }
}
